<template>
  <div>
    <img :src="url" alt="" />
    <p :style="{backgroundColor:color}" @click="add">{{ uname }}</p>
  </div>
</template>

<script>
export default {
  props: ['url', 'uname'],
  data(){
  return{
  color:''
  }
  },
  methods: {
    add() {
    this.color=`rgb(${Math.floor(Math.random()*256)},${Math.floor(Math.random()*256)},${Math.floor(Math.random()*256)})`
      this.$emit('love', this.uname)
    },
  },
}
</script>

<style scoped>
div {
  border: 1px solid black;
  margin-left: 30px;
  width: 25%;
  float: left;
}
img {
  width: 100%;
  height: 450px;
  overflow: hidden;
}
p {
  text-align: center;
}
</style>
